#ifndef WATERFALLBUTTONGROUP_H
#define WATERFALLBUTTONGROUP_H

#include "WaterFloatButton.h"

class WaterFallButtonGroup final : public QWidget {
    Q_OBJECT

public:
    explicit WaterFallButtonGroup(QWidget *parent = nullptr);

    void initStringList(const QStringList& list, const QStringList& selected = QStringList());

    void setSelects(const QStringList& list);

    void addButton(const QString& s, bool selected = false);

    void addButton(const QString& s, const QColor& c, bool selected = false);

    void clearButtons();

    void setSelecteable(bool en);

    void setColors(QColor normal_bg, QColor hover_bg, QColor press_bg, QColor selected_bg, QColor normal_ft,
                   QColor selected_ft = Qt::transparent);

    void setMouseColor(QColor hover_bg, QColor press_bg);

    void updateButtonPositions();

protected:
    void resizeEvent(QResizeEvent *event) override;

private:
    QColor getReverseColor(const QColor& color);

    int getReverseChannel(const int& x);

    void setBtnColors(InteractiveButtonBase *btn) const;

    void selectBtn(InteractiveButtonBase *btn) const;

signals:
    void signalSelected(QString s);

    void signalUnselected(QString s);

private:
    QList<InteractiveButtonBase *> btns;
    bool selectable = true;
    QColor normal_bg, hover_bg, press_bg, selected_bg, normal_ft, selected_ft;
};

#endif // WATERFALLBUTTONGROUP_H
